package com.yuanxiao.service;

import com.yuanxiao.pojo.Article;
import com.yuanxiao.repository.ArticleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleService {

    @Autowired
    private ArticleRepository repository;

    //分页获取所有文章

    public  Page<Article> getAll(int page, int size){

        PageRequest of = PageRequest.of(page, size);
        return repository.findAll(of);
    /*    List<Article> all = repository.findAll();
        return all;*/
    }

}
